﻿//
//This file contains all necessary functions for the bottom label bar with fullscreen and playback control buttons
//

//function for initial positioning of the label bar
function positionLegend()
{
    var legend = host.findName("legend");
    legend["Canvas.Top"] = host.ActualHeight;
    legend.Width = host.ActualWidth;
    
    var legendGradient = host.findName("legendGradient");
    legendGradient.Width = host.ActualWidth;
    
    var opacity = host.findName("legendAnimationOpacity");
    opacity.To = 0.0;
    opacity.Duration = "0:0:0.01";
        
    var top = host.findName("legendAnimationTop");
    top.To = host.ActualHeight - host.findName("legend").Height;
    top.Duration = "0:0:0.2";
}

//starts the fade-in animation for the legend (when user hovers over a picture with the mouse)
function showLegend(sender, eventArgs)
{
    for(var i = 0; i < images.length; i++)
    {
        if(images[i] == sender.Source)
            break;
    }
    
    //only show the legend, if there is a title or comment available for the image
    if((titles[i] != "") || (comments[i] != ""))
    {
        host.findName("txtTitle").Text = titles[i];
        host.findName("txtComment").Text = comments[i];

        var opacity = host.findName("legendAnimationOpacity");
        opacity.To = 1.0;
        opacity.BeginTime = "0:0:0";
        opacity.Duration = "0:0:0.1";
        
        var top = host.findName("legendAnimationTop");
        top.To = host.ActualHeight - host.findName("legend").Height;
        top.BeginTime = "0:0:0";
        top.Duration = "0:0:0.1";
        
        host.findName("legendAnimation").Begin();
    }
}

//starts the fade out animation for the legend (on mouseout of the image)
function hideLegend(sender, eventArgs)
{
    var opacity = host.findName("legendAnimationOpacity");
    opacity.To = 0.0;
    opacity.BeginTime = "0:0:1.5";
    opacity.Duration = "0:0:0.75";
    
    var top = host.findName("legendAnimationTop");
    top.To = host.ActualHeight;
    top.BeginTime = "0:0:1.5";
    top.Duration = "0:0:0.75";
    
    host.findName("legendAnimation").Begin();
}